package org.example.bean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class Animal {
    @Value("${animal.name}")
    private String name;
    @Value("${animal.age}")
    private Integer age;
    public Animal() {
    }

    public void setName(String name){
        this.name = name;
    }
    public String getName(){
        return this.name;
    }
    public void setAge(Integer age){
        this.age=age;
    }
    public Integer getAge(){
        return this.age;
    }

    public Animal(String name,Integer age){
        this.name = name;
        this.age = age;
    }
    @Autowired
    public String toString(){
        //string 需要额外处理格式
        return "Animal{"+"name='"+name+"'"+",age="+age+"}";
    }
}
